import React from 'react';

import './index.less';

import {render} from '../../../../../hrpub/common/frame';

import {
    base
} from 'nc-lightapp-front';

import BatchAction from '../../actions/batchAdd';
import ProTmp from '../../actions/processTmp';
import TableAction from '../../actions/table';
import RowHandleAction from '../../actions/rowHandle';
import OfferAction from '../../actions/offer';
import MainAction from './actions/main';

import EntryInfo from './components/EntryInfo';
import SelectMan from './components/SelectMan';

const {
    NCModal,
    NCStep,
    NCButton
} = base;

const {
    Header,
    Body,
    Footer
} = NCModal;

const {NCSteps} = NCStep;


export default render({
    actions: {
        batchAct: BatchAction,
        pAct: ProTmp,
        tableAct: TableAction,
        rowAct: RowHandleAction,
        offerAct: OfferAction,
        ma: MainAction
    },
    state: {
        selectAll: false,
        selectRows: null,
        modalHeight: 'auto'
    }
})(({props, state, action}) => {
    const {
        emp,
        form,
        search,
        editTable
    } = props;
    

    return (
        <NCModal
            show={emp.batchAddModalVisible}
            size="lg"ge
            onHide={action.batchAct.closeBatchModal}
            className="batch-add-modal batchModal"
            backdrop="static"
            onEntered={action.ma.setModalHeight}
            style={{
                height: state.modalHeight
            }}
        >
            <Header
                closeButton={true}
            >
                {emp.language['gx6008-000057']/** 批量新增 */}
            </Header>
            <Body>
                <div 
                    className="batch-add-modal-content"
                >
                    <div className="batch-add-modal-step-wrapper">
                        <NCSteps
                            current={emp.batchAddCurrentStep}
                        >
                            <NCStep
                                title={emp.language['gx6008-000058']/** "选择人员" */}
                            />
                            <NCStep
                                title={emp.language['gx6008-000278']/** "离职信息" */}
                            />
                        </NCSteps>
                    </div>
                    <If condition={emp.batchAddCurrentStep === 0}>
                        <SelectMan 
                            pk_org={emp.orgValue ? emp.orgValue.refpk : ''}
                            search={search}
                            language={emp.language}
                            editTable={editTable}
                            changePersonRefer={action.batchAct.changePersonRefer}
                            selectedAll={action.batchAct.selectedAll}
                            openBatchAddSearchModal={action.batchAct.openBatchAddSearchModal}
                        />
                    <Else/>
                        <EntryInfo 
                            form={form}
                            beforeEdit={action.batchAct.formBeforeEdit}
                            afterEdit={action.batchAct.formAfterEdit}
                        />
                    </If>
                    <div style={{
                        display: 'none'
                    }}>
                        {props.search.NCCreateSearch('batchaddmultiadd', {
                            clickSearchBtn: action.batchAct.toSearchWrapper
                        })}
                    </div>
                </div>
            </Body>
            <Footer>
                <div className="batch-add-modal-footer">
                    <NCButton
                        disabled={emp.batchAddCurrentStep === 0}
                        onClick={action.batchAct.goToPrevStep}
                    >
                        {emp.language['gx6008-000062']/** 上一步 */}
                    </NCButton>
                    <NCButton
                        disabled={emp.batchAddCurrentStep === 1}
                        onClick={action.batchAct.goToNextStep}
                    >
                        {emp.language['gx6008-000063']/** 下一步 */}
                    </NCButton>
                    <NCButton
                        disabled={emp.batchAddCurrentStep === 0}
                        onClick={action.batchAct.submitBatchAdd}
                    >
                        {emp.language['gx6008-000064']/** 完成 */}
                    </NCButton>
                    <NCButton
                        onClick={action.batchAct.closeBatchModal}
                    >
                        {emp.language['gx6008-000025']/** 取消 */}
                    </NCButton>
                </div>
            </Footer>
        </NCModal>
    );

});